  import { defineStore } from "pinia";
  import { ref } from "vue";
  import {getLoginUserUsingPost} from "@/api/userController.ts";

  export const useLoginUserStore = defineStore("loginUser", () => {
    const loginUser = ref<API.UserLoginVO>({
      userName: "未登录",
    });

    /**
     * 获取登录用户
     */
    async function fetchLoginUser() {
      const res = await getLoginUserUsingPost();
      if (res.data.code === 200 && res.data.data) {
        loginUser.value = res.data.data;
      }
    }

    function setLoginUser(newLoginUser: any) {
      loginUser.value = newLoginUser;
    }



    return { loginUser, setLoginUser, fetchLoginUser}
  });

